import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'

import user from './user'
import menu from './menu'
import tagsView from './tagsView'
Vue.use(Vuex)

const vuexLocal = new VuexPersistence({
    storage: window.sessionStorage,
    modules: ['user','menu']
})
const getters ={
    token:state => state.user.token,
    needRestPwd: state => state.user.needRestPwd,
    initMenu: state => state.menu.menus && state.menu.menus.length,
    authorization: (state) => {
        return {
            Authorization: state.user.token || ''
        }
    }
}

export default new Vuex.Store({
    modules: {user,menu,tagsView},
    plugins:[vuexLocal.plugin],
    getters
})
